package com.xuecheng.search.controller;

import com.xuecheng.api.search.CoursePubSearchApi;
import com.xuecheng.api.search.model.CoursePubIndexDTO;
import com.xuecheng.api.search.model.qo.QueryCoursePubModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.domain.response.RestResponse;
import com.xuecheng.search.service.CoursePubSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 课程搜索服务控制层
 */
@RestController
@RequestMapping
public class CoursePubSearchController implements CoursePubSearchApi {
    @Resource
    private CoursePubSearchService couresPubSearchService;
    @PostMapping("course_index")
    public PageVO<CoursePubIndexDTO> coursePubIndexByCondition(PageRequestParams pageParams, @RequestBody QueryCoursePubModel queryModel) {
        PageVO<CoursePubIndexDTO> pageVO = couresPubSearchService.queryCoursePubIndex(pageParams, queryModel);
        return pageVO;
    }

    @Autowired
    private CoursePubSearchService coursePubSearchService;
    @GetMapping("course_pub/{coursePubId}")
    public CoursePubIndexDTO getCoursePubById(@PathVariable Long coursePubId) {
        CoursePubIndexDTO respo =
                coursePubSearchService.getPubIndexById(coursePubId);
        return respo;
    }

    @GetMapping("l/course_pub/{coursePubId}")
    public RestResponse getCoursePubById4s(@PathVariable Long coursePubId) {
        RestResponse<CoursePubIndexDTO> respo =
                coursePubSearchService.getCoursePubIndexById4s(coursePubId);
        return respo;
    }
}
